import * as createTypes from './createTypes'
import { fromJS } from 'immutable'

const defaultValue = fromJS({
    focused: false,
    monseIn: false,
    list: [],
    //请求搜索内容分页显示
    page: 1,
    totalPage: 1
    
})

export default (state = defaultValue, action) => {
    switch (action.type) {
        case createTypes.CHANGE_INPUT_FOCUSED:
            return state.set('focused', true)
        case createTypes.CHANGE_INPUT_BLUR:
            return state.set('focused', false)
        case createTypes.GET_LIST:
            // console.log(action)  action 中存放获取的所有数据
            return state.set('list', action.data).set('totalPage', action.totalPage)
        case createTypes.MOUSE_ENTER:
            return state.set('monseIn', true)
        case createTypes.MOUSE_LEAVE:
            return state.set('monseIn', false)
        case createTypes.CHANGE_PAGE:
            return state.set('page', action.page)
        default:
            return state
    }

}